package com.aaa.custom.dao.Products;

import com.aaa.entity.cart_order.zxh.Product;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * fileName:ProductsDao
 * description:
 * author:zxh
 * createTime:2020/2/14 15:35
 * version:1.0.0
 */
public interface ProductsDao {

    /**
     * 查询单个商品
     * @param product_id
     * @return
     */
    @Select("select id as product_id,brand_id,product_category_id,name,pic,product_attribute_category_id,price," +
            "delete_status,publish_status,new_status,recommand_status,sale,promotion_price," +
            "gift_point,original_price,stock,low_stock,promotion_per_limit,product_category_name" +
            " from pms_product where id=#{product_id}")
    Product OneProductById(Long product_id);

    /**
     * 查询商品库存
     * @param product_id
     * @return
     */
    @Select("select stock from pms_product where id=#{product_id}")
    Integer ProductStockbyId(Long product_id);

    /**
     * 库存数目加
     * @param product_id
     * @param ProductAmount
     * @return
     */
    @Update("update pms_product set stock=stock+${ProductAmount} where id=#{product_id}")
    Integer ProductStockAddbyId(@Param("product_id") Long product_id,@Param("ProductAmount") Integer ProductAmount);

    /**
     * 库存数目减
     * @param product_id
     * @param ProductAmount
     * @return
     */
    @Update("update pms_product set stock=stock+${ProductAmount} where id=#{product_id}")
    Integer ProductStockSubtractbyId(@Param("product_id") Long product_id,@Param("ProductAmount") Integer ProductAmount);
}
